home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / utils / bibtools / bibkey.awk < prev    next >
Text File  |  1992-09-03  |  740b  |  34 lines

  1. # bibkey.awk 
  2. #
  3. # Goes with bin/bibkey - look for a word in the keyword entry 
  4. #
  5. # David Kotz (dfk@cs.dartmouth.edu)
  6. #
  7. # On stdin, we get a list of line numbers of the beginning of entries
  8. # (in the concatenated bibtex input) and the text of lines from keyword
  9. # entries  that have the keyword in them.
  10. #
  11. # On stdout, we produce a sed script for printing entries that had a
  12. # match in them somewhere. This is a list of lines like "A,Bp" where A
  13. # and B are line numbers.
  14.  
  15. BEGIN {found=0; last=1}
  16.  
  17. {
  18. # test: is line a number?
  19.     if ($1+0 > 0) {
  20.            if (found) {
  21.                   print last "," $1-1 "p";
  22.                   found=0
  23.            }
  24.            last=$1
  25.     } else {
  26.        found = 1
  27.     }
  28. }
  29.  
  30. END {
  31.     if (found)
  32.         print last ",$p";
  33. }
  34.